<?php

class Con_index extends Acan{
	
	public $defaultAct='abody';
	function __construct($ainfo=null){
		parent::__construct($ainfo=null);
		$this->newup;
	}
	//后台框架
	function Act_abody(){
		$anav_data = Afunc_nav()->anav_data('asys',$this->Amode,$this->Aapp);//获取菜单
		if($this->Amode == '0'){$if_start = $this->Aapp.'-';}else{$if_start='';}
		$default_url = $if_start.'index-index';
		include $this->Atpl('public/abody');
	}
	//后台首页
	function Act_index(){
		/*$mg = new Mongo();
		$db = $mg->Acan_sys;
		$analysis = $db->analysis;
		$db->selectCollection("analysis");
		$obj->sdf = array('time'=>'0.125','act'=>'index','mod'=>'index','app'=>'asys');
		$analysis->insert($obj);
		print_r($analysis->count());
		*/
		/*
		var_dump(Afunc_option('mail')->get());
		var_dump(Afunc_option('mail')->set("sdfsd@qqsd.com"));
		var_dump(Afunc_option('mail')->get());
		*/
		$os = Afun_get_os();
		$datetime = Afun_get_time();
		if($_GET['do']=='phpinfo'){
			echo "时间:".time();
			phpinfo();
			exit;
		}
		if($_POST['tomail']){
			$tomail=$_POST['tomail'];
			$toname=$_POST['toname'];
			$title=$_POST['title'];
			$body=$_POST['body'];
			$amail = Afun_mail($tomail,$toname,$title,$body);
		}

		$form_val_cache = array('atpl'=>'模板缓存','ahtml'=>'静态文件缓存','file'=>'文件缓存');
		$form_chk_cache = $apo['clear'];
		$form_chk_cache['atpl']='atpl';
		$form_val_eaccelerator = array('disk'=>'磁盘缓存','mem'=>'内存缓存');
		//--清理缓存
		if($apo['clear']){
			$Aclass_file = Afunc_file();
			//print_r($apo);
			if(!empty($apo['clear']['atpl'])){
				if($Aclass_file->armdir_child(A_ROOT.'/temp/tpl_cache/'))
					echo '清理模板成功';
			}
			if(!empty($apo['clear']['ahtml'])){
				if($Aclass_file->armdir_child(A_ROOT.'/temp/ahtml/'))
					echo '清理静态文件成功';
			}
		}
		
		include $this->Atpl();
	}
	//后台框架
	function Act_html5(){
		include $this->Atpl();
	}
	function area(){
		
		$area = Afun_db()->model('acan_area');
		$model = $area->findAll('class=1');
		foreach($model as $k=>$v){
			$sh[$v['name']] = $v['id'];
		}
		$model = $area->findAll('class=2');
		foreach($model as $k=>$v){
			$shis[$v['tel']] = $v['id'];
		}
		$xls = Afun_acan_new('xls',A_ROOT.'code.xls');
		$data = $xls->getdata();
		$sheng = '';
		$i = 0;
		foreach($data as $key=>$val){
			$aa['name'] = trim($val[1]);
			$aa['tel'] = trim($val[2]);
			$aa['zip'] = (int)$val[3];
			$aa['pid'] = trim($val[7]);
			$bb['name'] = trim($val[4]);
			$bb['tel'] = trim($val[5]);
			$bb['zip'] = (int)$val[6];
			$bb['pid'] = trim($val[7]);
			if(strlen($aa['zip'])==5){
				$aa['zip'] = "0".$aa['zip'];
			}
			if(strlen($bb['zip'])==5){
				$bb['zip'] = "0".$bb['zip'];
			}
			if(substr($aa['tel'],0,1)!='0'){
				$aa['tel'] = "0".$aa['tel'];
			}
			if(substr($bb['tel'],0,1)!='0'){
				$bb['tel'] = "0".$bb['tel'];
			}
			if($sheng != $val[7]){
				$slist[] = $val[7];
				$sheng = $val[7];
				$aa['class']='2';
				$aa['pid'] = $sh[$sheng];
				$aa['hui']='1';
			}
			if($shi != $aa['tel'] || $aa['pid']=='北京' || $aa['pid']=='上海' || $aa['pid']=='重庆' || $aa['pid']=='天津'){
				$shilist[] = $aa['name'];
				$shi = $aa['tel'];
				$aa['pid'] = $sh[$sheng];
				$aa['class']='2';
			}
			if(empty($aa['class'])){
				$aa['class']='3';
				$aa['pid'] = $shis[$shi];
			}
			if($bb['pid']=='北京' || $bb['pid']=='上海' || $bb['pid']=='重庆' || $bb['pid']=='天津'){
				$shilist[] = $aa['name'];
				$bb['pid'] = $sh[$sheng];
				$bb['class']='2';
			}else{
				$bb['pid'] = $shis[$shi];
				$bb['class']='3';
			}
			$list[] = $aa;
			if(!empty($bb['name'])){
				$list[] = $bb;
			}
			unset($aa,$bb);
		}
	//	print_r($list);
	//	print_r($shilist);
		
		/*
		foreach($list as $k=>$v){
			if($v['class']=='2'){
				print_r($v);
				$area->save($v);
			}
		}*/
		$i = 0;
		foreach($list as $k=>$v){
			if($v['class']=='3'){
				//print_r($v);
				$i++;
				//$area->save($v);
			}
		}
		echo $i;
	}
	function Act_linux(){
		if($_POST){
			$terminal = $_POST['terminal'];
			$msg = "命令:".$terminal.'<hr>';
			$content = '<?php'."\n";
			$content .= 'echo `'.$terminal.'`;';
			$content .= "\n".'?>';
			if(!is_dir(A_ROOT.'temp/linux/')){
				Afunc_file()->amkdirm(A_ROOT.'temp/linux/');
			}
			file_put_contents(A_ROOT.'temp/linux/terminal.php',$content);
			echo '1';
			exit;
		}
		include_once $this->Atpl();
	}
}

?>